58c093
@@ -284,7 +284,7 @@
public int read(byte[] buf, int off, int len) throws IOException {
             }
         }
         int secondCount = in.read(buf, off, len);
-        return (secondCount < 0) ? firstCount : firstCount + secondCount;
+        return (secondCount < 0) ? (firstCount > 0 ? firstCount : -1) : firstCount + secondCount;
     }
 
     /**
